<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>评论管理</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input, textarea {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
        }
        button {
            padding: 10px 15px;
            background-color: #007bff;
            color: white;
            border: none;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .comment-list {
            margin-top: 20px;
        }
        .comment-item {
            border: 1px solid #ddd;
            padding: 10px;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>评论管理</h1>
    
    <!-- 添加评论表单 -->
    <form action="#" th:action="@{/api/comments}" method="post">
        <div class="form-group">
            <label for="content">评论内容</label>
            <textarea id="content" name="content" rows="4" required></textarea>
        </div>
        <div class="form-group">
            <label for="author">作者</label>
            <input type="text" id="author" name="author" required>
        </div>
        <div class="form-group">
            <label for="aId">关联ID</label>
            <input type="number" id="aId" name="aId" required>
        </div>
        <button type="submit">提交评论</button>
    </form>

    <!-- 评论列表 -->
    <div class="comment-list">
        <h2>评论列表</h2>
        <div th:each="comment : ${comments}" class="comment-item">
            <p><strong>ID:</strong> <span th:text="${comment.id}"></span></p>
            <p><strong>内容:</strong> <span th:text="${comment.content}"></span></p>
            <p><strong>作者:</strong> <span th:text="${comment.author}"></span></p>
            <p><strong>关联ID:</strong> <span th:text="${comment.aId}"></span></p>
            <a th:href="@{/api/comments/{id}/edit(id=${comment.id})}">编辑</a>
            <a th:href="@{/api/comments/{id}/delete(id=${comment.id})}" onclick="return confirm('确定要删除吗？')">删除</a>
        </div>
    </div>
</div>
</body>
</html>